package com.xmy.cultivate.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xmy.cultivate.entity.Area;
import com.xmy.cultivate.service.IAreaService;
import com.xmy.cultivate.util.Code;
import com.xmy.cultivate.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 区域表 前端控制器
 * </p>
 *
 * @author hpiggy
 * @since 2025-02-09
 */
@RestController
@RequestMapping("/api/area")
public class AreaController {

    @Autowired
    IAreaService iAreaService;

    @GetMapping("/getAreaOne")
    public Result getAreaOne() {

        List<Area> areaList = iAreaService.findByTypeForOne();
        return new Result(Code.OK, areaList, Code.GET_OK_MSG);

    }


    /**获取意向区域
     * @param
     */
    @GetMapping("/getAreaList")
    public Result getAreaList() {

        QueryWrapper<Area> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("status", 1);
        queryWrapper.eq("deleted", 0);
        List<Area> areaList = iAreaService.list(queryWrapper);
        return new Result(Code.OK, areaList, Code.GET_OK_MSG);

    }

}
